<?php
class PmaimaiComponent extends Component {
	var $controller;
	
	function startup(&$controller) {
		$this->controller =& $controller;
	}
	
	function checkMemberAuth()
	{
		if(!$this->controller->Session->check($this->controller->sessionUserName)){
			$this->controller->set('error', false);
			$this->controller->render(null, null, '/users/login');
			exit;
		}
	}
	
	/**
	 * Cleans an array or string for SQL and HTML, by reference
	 * 
	 * @param mixed &$subject
	 */
	function clean(&$subject, $stripTags = false) 
	{
		if (isset($subject)) {
			if (is_array($subject)) {
				foreach ($subject as $k => $v) {
					$this->clean($subject[$k], $stripTags);
				}
			}
			else {
				if ($stripTags)
					$subject = strip_tags($subject);
				if (!class_exists('Sanitize')) {
					uses ('sanitize');
				}
				$subject = Sanitize::escape($subject);
			}
		}
	}

}
?>
